package com.ruoyi.chat.request.chat;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.util.Arrays;
import java.util.List;

@Data
public class DataSetsRequest {

    @JsonProperty
    private String name;

    @JsonProperty
    private String avatar;

    @JsonProperty
    private String description;

    @JsonProperty(value = "embedding_model")
    private String embeddingModel;

    @JsonProperty
    private String permission;

    /** 用于删除知识库 */
    @JsonProperty
    private List<String> ids;

    /**
     * "naive"：常规（默认）
     * "manual"：手动
     * "qa"： 问答
     * "table"：桌子
     * "paper"：纸
     * "book"：书
     * "laws"：法律
     * "presentation"：介绍
     * "picture"：图片
     * "one"：一
     * "knowledge_graph"：知识图
     * 谱 在选择此选项之前，请确保在 Settings （设置） 页面上正确配置了 LLM。另请注意，知识图谱会消耗大量的 Token！
     * "email"：电子邮件
     */
    @JsonProperty(value = "chunk_method")
    private String chunkMethod;

    @JsonProperty(value = "parser_config")
    private Object parserConfig;

    @Data
    static class NaiveParserConfig {
        @JsonProperty(value = "chunk_token_count")
        private int chunkTokenCount = 128;

        @JsonProperty(value = "layout_recognize")
        private boolean layoutRecognize = true;

        @JsonProperty
        private boolean html4excel = false;

        @JsonProperty
        private String delimiter = "\n!?。；！？";

        @JsonProperty(value = "task_page_size")
        private int taskPageSize = 12;

        @JsonProperty
        private UserRaptor raptor;
    }

    @Data
    static class TextParserConfig {
        @JsonProperty
        private UserRaptor raptor;
    }

    // 空parserConfig
    @Data
    static class BlankParserConfig {
    }

    @Data
    static class KnowledgeGraphParserConfig {
        @JsonProperty(value = "chunk_token_count")
        private int chunkTokenCount = 128;

        @JsonProperty
        private String delimiter = "\n!?。；！？";

        @JsonProperty(value = "entity_types")
        private String[] entityTypes = new String[]{"organization","person","location","event","time"};
    }

    @Data
    static class UserRaptor {
        @JsonProperty(value = "use_raptor")
        private boolean useRaptor = false;
    }
}
